export default (target) => {
    target.getEvTarget = (ev) => {
        let e = ev || window.event;
        return e.target || e.srcElement;
    }
    target.tplReplace = (template, templateData) => {
        return template().replace(/{{(.*?)}}/g, (match, key) => {
            return templateData[key]
        })
    }
    target.trimSpace = (str) => {
        return str.replace(/\s+/g, '');
    }
    target.throttle = (fn, delay) => {
        let t = null,
            beginTime = new Date().getTime();
        return function() {
            let _this = this,
                args = arguments,
                currentTime = new Date().getTime();
            if (currentTime - beginTime >= delay) {
                beginTime = currentTime;
                fn.apply(_this, args);
            } else {
                clearTimeout(t);
                setTimeout(function () {
                    fn.apply(_this, args);
                }, delay)
            }
        }
    }
}